package org.dtrd.modules.message.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author xiao
 * @date 2022/6/19 4:46 PM
 */
@Configuration
public class MessagePushConfiguration {

    @Value("${dtrd.push.config.platforms.officialAccount}")
    private Boolean officialAccountEnable;

    @Value("${dtrd.push.config.platforms.sms}")
    private Boolean smsEnable;

    @Value("${dtrd.push.config.includeIds}")
    private String includeIds;

    @Bean
    public void initMessagePushConfiguration() {
        if (includeIds != null && includeIds.length()>0) {
            String[] array = includeIds.split(",");
            List<Integer> idList = new ArrayList<>(array.length);
            System.out.println("MessagePushConfiguration.initWechatConfiguration includeIds==" + includeIds + "; idList==" + idList);
            Arrays.stream(array).map(Integer::valueOf).forEach(idList::add);
            MessagePushConfig.setPushEnablePatientIdList(idList);
        }
    }

}
